import 'package:flutter/material.dart';
import 'detail_page.dart';
import 'user_center.dart';

class SecondPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return new SecondHomeState();
  }
}

class SecondHomeState extends State {
  void _goToUserCenter() {
    Navigator.push(context, new MaterialPageRoute(builder: (context) => new UserCenter()));
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
        appBar: new AppBar(
          title: new Text("考核项目"),
          actions: <Widget>[
            new IconButton(
                icon: new Icon(Icons.person), onPressed: _goToUserCenter)
          ],
        ),
        body: new ListView(
          children: <Widget>[
            new Item("第十六届代表大会"),
            new Item("联系群众"),
            new Item("普法宣传"),
            new Item("好雨知时节当春乃发生")
          ],
        ));
  }
}

class Item extends StatefulWidget {
  final String title;

  Item(this.title);

  @override
  State<StatefulWidget> createState() {
    return new ItemState(title);
  }
}

class ItemState extends State {
  String title;

  ItemState(this.title);

  @override
  Widget build(BuildContext context) {
    return new GestureDetector(
        onTap: () {
          Navigator.push(
              context,
              new MaterialPageRoute(
                  builder: (context) => new DetailPage(title)));
        },
        child: new Padding(
          padding: const EdgeInsets.all(10.0),
          child: new Row(
            children: <Widget>[
              new Expanded(
                  child: new Text(
                title,
                style: new TextStyle(fontSize: 20.0),
              )),
              new Icon(
                Icons.navigate_next,
                color: Colors.black12,
                size: 40.0,
              )
            ],
          ),
        ));
  }
}
